import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:shop/model/MyModelNotifier.dart';
import 'package:shop/provider/provider_widget.dart';

class MyModelScreen extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _MyModelScreen();
  }
}

class _MyModelScreen extends State<MyModelScreen> {
  @override
  Widget build(BuildContext context) {

    return Scaffold(
      appBar: AppBar(
        title: Text("MyModelScreen"),
      ),
      body: Container(
        child: Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              Center(
                child: Text("${Provider.of<MyModelNotifier>(context).count}")
              ),

              Consumer(builder: (context, MyModelNotifier myModel, child)=>Center(
                child: Text("${myModel.count}"),
              ))

              // ProviderWidget<MyModelNotifier>(
              //   builder: (context, model, child){
              //     return Center(
              //       child: Column(
              //         children: <Widget>[
              //           Text("${model.count}"),
              //
              //           Padding(
              //             padding: const EdgeInsets.all(8.0),
              //             child: FlatButton(
              //               color: Colors.tealAccent,
              //               onPressed: ()=>model.increment(),
              //               child: Icon(Icons.add),
              //             ),
              //           ),
              //         ],
              //       ),
              //     );
              //   },
              //   model: Provider.of(context),
              // ),
            ],
          ),
        ),
      ),
    );
  }
}
